<?php
allowCors();
if (!methodsRequired(['get'])) return;
if (!checkAdmin($msg)) return;
$page = 1;
$pageSize = 10;
if (isset($_REQUEST['page']) && isset($_REQUEST['pageSize'])) {
    $page = $_REQUEST['page'];
    $pageSize = $_REQUEST['pageSize'];
}

$result = $db->list(["class" => "Department"], $page, $pageSize);
$msg->data["list"] = $result['list'];
$msg->data["totalCount"] = count($msg->data["list"]);
$msg->data["total"] = $result['total'];
$msg->data["currentPage"] = (int)$page;
echo $msg;
